//
//  DetailsOfMeetingFromMeeting.m
//  Gxj
//
//  Created by 刘伟 on 2017/9/18.
//  Copyright © 2017年 wkq. All rights reserved.
//

#import "DetailsOfMeetingFromMeeting.h"
#import "UILabel+ChangeLineSpaceAndWordSpace.h"

@implementation DetailsOfMeetingFromMeeting

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        [self addSubview:self.userHeadView];
        [self.userHeadView addSubview:self.iconTouxiang];// 用户头像
        [self addSubview:self.nameText];// 用户名字
        [self addSubview:self.iconXunzhang];// 等级勋章
        [self addSubview:self.textDengji];// 等级内容
        [self addSubview:self.iconGuankan];// 浏览人数图标
        [self addSubview:self.numLable];// 浏览人数
        [self addSubview:self.contentText];// 发表内容
        [self.imageFabiao addSubview:self.countdownLab];// 倒计时
        [self addSubview:self.iconShijian];// 时间图标
        [self addSubview:self.shiJianText];// 会议开始时间
        [self addSubview:self.guanzhuBut];// 关注按钮
        [self addSubview:self.shangYeText];// 简介
        [self addSubview:self.imageFabiao];// 用户发表图片
        [self addSubview:self.titleLab]; // 会议标题
        [self addSubview:self.thumpUp];
        [self addSubview:self.thumpUpNum];
        [self.imageFabiao addSubview:self.labellingLab];
        [self.imageFabiao addSubview:self.labellingLab1];
        [self.imageFabiao addSubview:self.startView];
        [self.startView addSubview:self.startLab];
        [self.startView addSubview:self.startImage];
        [self showDetailsOfMeetingHeadView];
    }
    return self;
}

- (void)showDetailsOfMeetingHeadView
{
    _userHeadView.sd_layout
    .topSpaceToView(self, kHeightScale(10))
    .leftSpaceToView(self, kWidthScale(15))
    .widthIs(kWidthScale(25))
    .heightIs(kHeightScale(25));
    
    _iconTouxiang.sd_layout
    .topSpaceToView(self.userHeadView, kHeightScale(2))
    .leftSpaceToView(self.userHeadView, kWidthScale(2))
    .rightSpaceToView(self.userHeadView,kWidthScale(2))
    .bottomSpaceToView(self.userHeadView,kHeightScale(2));
    
    _nameText.sd_layout
    .topEqualToView(self.userHeadView)
    .leftSpaceToView(self.userHeadView,kWidthScale(5))
    .widthIs(kWidthScale(150))
    .autoHeightRatio(0);
    
    _guanzhuBut.sd_layout
    .centerYEqualToView(self.userHeadView)
    .rightSpaceToView(self,kWidthScale(15))
    .widthIs(kWidthScale(60))
    .heightIs(kHeightScale(25));
    
    _iconXunzhang.sd_layout
    .topSpaceToView(self.nameText,kHeightScale(3))
    .leftEqualToView(self.nameText)
    .widthIs(kWidthScale(11))
    .heightIs(kHeightScale(11));
    
    _textDengji.sd_layout
    .centerYEqualToView(self.iconXunzhang)
    .leftSpaceToView(self.iconXunzhang,kWidthScale(3))
    .autoHeightRatio(0);
    [_textDengji setSingleLineAutoResizeWithMaxWidth:kWidthScale(40)];
    
    _titleLab.sd_layout
    .topSpaceToView(self.iconXunzhang,kHeightScale(10))
    .leftEqualToView(self.userHeadView)
    .rightSpaceToView(self,kWidthScale(15))
    .autoHeightRatio(0);
    
    _iconShijian.sd_layout
    .topSpaceToView(self.titleLab,kHeightScale(5))
    .leftEqualToView(self.titleLab)
    .widthIs(kWidthScale(11.5))
    .heightIs(kHeightScale(11.5));
    
    _shiJianText.sd_layout
    .centerYEqualToView(self.iconShijian)
    .leftSpaceToView(self.iconShijian,kWidthScale(5))
    .autoHeightRatio(0);
    [_shiJianText setSingleLineAutoResizeWithMaxWidth:kWidthScale(40)];
    
    _iconGuankan.sd_layout
    .centerYEqualToView(self.iconShijian)
    .leftSpaceToView(self.shiJianText,kWidthScale(10))
    .widthIs(kWidthScale(13))
    .heightIs(kHeightScale(8.6));
    
    _numLable.sd_layout
    .centerYEqualToView(self.iconShijian)
    .leftSpaceToView(self.iconGuankan,kWidthScale(5))
    .autoHeightRatio(0);
    [_numLable setSingleLineAutoResizeWithMaxWidth:kWidthScale(40)];
    
    _thumpUp.sd_layout
    .centerYEqualToView(self.iconShijian)
    .leftSpaceToView(self.numLable,kWidthScale(10))
    .widthIs(kWidthScale(11.5))
    .heightIs(kHeightScale(11.5));
    
    _thumpUpNum.sd_layout
    .centerYEqualToView(self.iconShijian)
    .leftSpaceToView(self.thumpUp,kWidthScale(5))
    .autoHeightRatio(0);
    [_thumpUpNum setSingleLineAutoResizeWithMaxWidth:kWidthScale(100)];
    
    _imageFabiao.sd_layout
    .topSpaceToView(self.iconShijian,kHeightScale(5))
    .leftEqualToView(self.userHeadView)
    .rightEqualToView(self.guanzhuBut)
    .heightIs(kHeightScale(150));
    
    _labellingLab.sd_layout
    .topSpaceToView(self.imageFabiao,kHeightScale(5))
    .leftSpaceToView(self.imageFabiao,kWidthScale(5))
    .widthIs(kWidthScale(35))
    .heightIs(kHeightScale(15));
    
    _labellingLab1.sd_layout
    .topSpaceToView(self.imageFabiao,kHeightScale(5))
    .leftSpaceToView(self.labellingLab,kWidthScale(5))
    .widthIs(kWidthScale(35))
    .heightIs(kHeightScale(15));
    
    _shangYeText.sd_layout
    .topSpaceToView(self.imageFabiao,kWidthScale(5))
    .leftEqualToView(self.imageFabiao)
    .rightEqualToView(self.imageFabiao)
    .autoHeightRatio(0);
    
    _startView.sd_layout
    .topSpaceToView(self.imageFabiao,kHeightScale(5))
    .rightSpaceToView(self.imageFabiao,kWidthScale(5))
    .widthIs(kWidthScale(47))
    .heightIs(kHeightScale(15));
    
    _startImage.sd_layout
    .centerYEqualToView(self.startView)
    .leftSpaceToView(self.startView,kWidthScale(5))
    .widthIs(kWidthScale(8))
    .heightIs(kHeightScale(10));
    
    _startLab.sd_layout
    .centerYEqualToView(self.startImage)
    .leftSpaceToView(self.startImage,kWidthScale(2))
    .rightSpaceToView(self.startView,kWidthScale(2))
    .heightIs(kHeightScale(10));
}

// 用户头像
- (UIButton *)iconTouxiang
{
    if (!_iconTouxiang)
    {
        _iconTouxiang = [UIButton buttonWithType:UIButtonTypeCustom];
        [_iconTouxiang setImage:[UIImage imageNamed:@"toixiang"] forState:0];
        _iconTouxiang.layer.cornerRadius = kWidthScale(12);
//        _iconTouxiang.layer.shadowColor   = [UIColor blackColor].CGColor;
//        _iconTouxiang.layer.shadowOffset  = CGSizeMake(kWidthScale(-3),kWidthScale(-3));
//        _iconTouxiang.layer.shadowRadius  = 6.f;
//        _iconTouxiang.layer.shadowOpacity = 0.3;
    }
    return _iconTouxiang;
}
// 用户名字
- (UILabel *)nameText
{
    if (!_nameText)
    {
        _nameText = [[UILabel alloc] init];
        _nameText.text = @"每天都蹲点";
        _nameText.font = [UIFont systemFontOfSize:kWidthScale(12)];
        _nameText.textColor = [UIColor colorWithHexString:@"#333333"];
    }
    return _nameText;
}
// 等级勋章
- (UIImageView *)iconXunzhang
{
    if (!_iconXunzhang)
    {
        _iconXunzhang = [[UIImageView alloc] init];
        _iconXunzhang.image = [UIImage imageNamed:@"dengjis"];
    }
    return _iconXunzhang;
}
// 等级内容
- (UILabel *)textDengji
{
    if (!_textDengji)
    {
        _textDengji = [[UILabel alloc] init];
        _textDengji.text = @"1级";
        _textDengji.textColor = [UIColor lightGrayColor];
        _textDengji.font = [UIFont systemFontOfSize:kWidthScale(11)];
        [_textDengji updateLayout];
    }
    return _textDengji;
}
// 浏览人数图标
- (UIImageView *)iconGuankan
{
    if (!_iconGuankan)
    {
        _iconGuankan = [[UIImageView alloc] init];
        _iconGuankan.image = [UIImage imageNamed:@"liulans"];
    }
    return _iconGuankan;
}
// 浏览人数
- (UILabel *)numLable
{
    if (!_numLable)
    {
        _numLable = [[UILabel alloc] init];
        _numLable.text = @"43";
        _numLable.textColor = [UIColor lightGrayColor];
        _numLable.font = [UIFont systemFontOfSize:kWidthScale(11)];
        [_numLable updateLayout];
    }
    return _numLable;
}
// 发表内容
- (UILabel *)contentText
{
    if (!_contentText)
    {
        _contentText = [[UILabel alloc] init];
    }
    return _contentText;
}
// 倒计时
- (UILabel *)countdownLab
{
    if (!_countdownLab)
    {
        _countdownLab = [[UILabel alloc] init];
    }
    return _countdownLab;
}
// 时间图标
- (UIImageView *)iconShijian
{
    if (!_iconShijian)
    {
        _iconShijian = [[UIImageView alloc] init];
        _iconShijian.image = [UIImage imageNamed:@"cxshijian"];
    }
    return _iconShijian;
}
// 会议开始时间
- (UILabel *)shiJianText
{
    if (!_shiJianText)
    {
        _shiJianText = [[UILabel alloc] init];
        _shiJianText.text = @"09:12";
        _shiJianText.textColor = [UIColor lightGrayColor];
        _shiJianText.font = [UIFont systemFontOfSize:kWidthScale(11)];
        [_shiJianText updateLayout];
    }
    return _shiJianText;
}
// 关注按钮
- (UIButton *)guanzhuBut
{
    if (!_guanzhuBut)
    {
        _guanzhuBut = [UIButton buttonWithType:UIButtonTypeCustom];
        [_guanzhuBut setImage:[UIImage imageNamed:@"guanzhu"] forState:0];
    }
    return _guanzhuBut;
}
// 简介
- (UILabel *)shangYeText
{
    if (!_shangYeText)
    {
        _shangYeText = [[UILabel alloc] init];
        _shangYeText.text = @"简介：读大学，哪怕不是一本二本，也可以让你在直面残酷的社会之前有个缓冲，不至于被虐的太惨！";
        _shangYeText.numberOfLines = 0;
        _shangYeText.textColor = [UIColor colorWithHexString:@"#666666"];
        _shangYeText.font = [UIFont systemFontOfSize:kWidthScale(11)];
//        [UILabel changeLineSpaceForLabel:_shangYeText WithSpace:kHeightScale(5)];
    }
    return _shangYeText;
}
// 用户发表图片
- (UIImageView *)imageFabiao
{
    if (!_imageFabiao)
    {
        _imageFabiao = [[UIImageView alloc] init];
        _imageFabiao.image = [UIImage imageNamed:@"ditu"];
        _imageFabiao.layer.cornerRadius = kWidthScale(12);
        _imageFabiao.layer.masksToBounds = YES;
    }
    return _imageFabiao;
}
// 会议标题
- (UILabel *)titleLab
{
    if (!_titleLab)
    {
        _titleLab = [[UILabel alloc] init];
//        _titleLab.textColor = [UIColor whiteColor];
//        _titleLab.textAlignment = NSTextAlignmentCenter;
//        _titleLab.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
        _titleLab.font = [UIFont systemFontOfSize:kWidthScale(13)];
        _titleLab.text = @"为什么要读大学?";
    }
    return _titleLab;
}

- (UIView *)userHeadView
{
    if (!_userHeadView)
    {
        _userHeadView = [[UIView alloc] init];
        _userHeadView.backgroundColor = [UIColor colorWithRed:(213.0/255) green:(213.0/255) blue:(213.0/255) alpha:1];;
        _userHeadView.layer.masksToBounds=YES;
        _userHeadView.layer.cornerRadius=12.5;
        _userHeadView.layer.shadowColor = [UIColor blackColor].CGColor;
        _userHeadView.layer.shadowOffset = CGSizeMake(-3, 1);
        _userHeadView.layer.shadowOpacity = 0.4;
        _userHeadView.layer.shadowRadius = 2.0;
        _userHeadView.clipsToBounds = NO;
    }
    return _userHeadView;
}

// 暂定View
- (UIView *)shadowView
{
    if (!_shadowView)
    {
        _shadowView = [[UIView alloc] init];
    }
    return _shadowView;
}

- (UIView *)startView
{
    if (!_startView)
    {
        _startView = [[UIView alloc] init];
        _startView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.4];
        _startView.layer.cornerRadius = kWidthScale(5);
        _startView.layer.masksToBounds = YES;
    }
    return _startView;
}

- (UIImageView *)startImage
{
    if (!_startImage)
    {
        _startImage = [[UIImageView alloc] init];
        _startImage.image = [UIImage imageNamed:@"daojishi"];
        _startImage.contentMode = UIViewContentModeScaleAspectFit;
    }
    return _startImage;
}

- (UILabel *)startLab
{
    if (!_startLab)
    {
        _startLab = [[UILabel alloc] init];
        _startLab.textColor = [UIColor whiteColor];
        _startLab.font = [UIFont systemFontOfSize:kWidthScale(10)];
        _startLab.text = @"08:15";
    }
    return _startLab;
}

- (UIButton *)thumpUp
{
    if (!_thumpUp)
    {
        _thumpUp = [UIButton buttonWithType:UIButtonTypeCustom];
        [_thumpUp setBackgroundImage:[UIImage imageNamed:@"zans"] forState:UIControlStateNormal];
    }
    return _thumpUp;
}

- (UILabel *)thumpUpNum
{
    if (!_thumpUpNum)
    {
        _thumpUpNum = [[UILabel alloc] init];
        _thumpUpNum.text = @"1111";
        _thumpUpNum.textColor = [UIColor colorWithHexString:@"#999999"];
        _thumpUpNum.font = [UIFont systemFontOfSize:kWidthScale(12)];
        [_thumpUpNum updateLayout];
    }
    return _thumpUpNum;
}

- (UILabel *)labellingLab
{
    if (!_labellingLab)
    {
        _labellingLab = [[UILabel alloc] init];
        _labellingLab.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        _labellingLab.textColor = [UIColor colorWithWhite:1 alpha:1];
        _labellingLab.font = [UIFont systemFontOfSize:kWidthScale(9)];
        _labellingLab.textAlignment = NSTextAlignmentCenter;
        _labellingLab.layer.cornerRadius = kWidthScale(5);
        _labellingLab.layer.masksToBounds = YES;
        _labellingLab.text = @"商业";
    }
    return _labellingLab;
}

- (UILabel *)labellingLab1
{
    if (!_labellingLab1)
    {
        _labellingLab1 = [[UILabel alloc] init];
        _labellingLab1.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
        _labellingLab1.textColor = [UIColor colorWithWhite:1 alpha:1];
        _labellingLab1.font = [UIFont systemFontOfSize:kWidthScale(9)];
        _labellingLab1.textAlignment = NSTextAlignmentCenter;
        _labellingLab1.layer.cornerRadius = kWidthScale(5);
        _labellingLab1.layer.masksToBounds = YES;
        _labellingLab1.text = @"商业";
    }
    return _labellingLab1;
}

@end
